package validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class ValidaNome implements Validator {

	@Override
	public void validate(FacesContext arg0, UIComponent arg1, Object value)
			throws ValidatorException {
		if (value == null) {
			return;
		}
		
		String nome = (String) value;
		if(nome.length()< 3){
			throw new ValidatorException(new FacesMessage(
					FacesMessage.SEVERITY_ERROR, "Nome muito curto", null));
			
		}

	}

}
